Use case: IRDA communication in polling mode ¶
This use case shows how to transmit or receive IRDA data in polling mode. In HAL2, IRDA support is handled via the HAL UART driver.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** IRDA Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
IRDA_HandleTypeDef hirda;
HAL_IRDA_Init(&hirda);
(void)HAL_IRDA_Receive(&hirda, aRxBuffer, DATA_TO_RECEIVE_SIZE, 100);
(void)HAL_IRDA_Transmit(&hirda, aTxBuffer, DATA_TO_SEND_SIZE, 100);
|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** IRDA Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
hal_uart_handle_t huart;
hal_uart_irda_config_t uart_irda_config;
HAL_UART_Init(&huart, HAL_UART4);
/* Configure IRDA mode on the UART instance */
HAL_UART_IRDA_SetConfig(&huart, &uart_irda_config);
(void)HAL_UART_Receive(&huart, aRxBuffer, DATA_TO_RECEIVE_SIZE, 100);
(void)HAL_UART_Transmit(&huart, aTxBuffer, DATA_TO_SEND_SIZE, 100);
|
Key changes ¶
In HAL2, the standalone IRDA driver is removed; use the HAL UART driver with IRDA configuration.
API names are updated from HAL_IRDA_* to HAL_UART_*.

